package demo;

public class Main {

    public static void main(String[] args) {

        try{
            String str="123456789";
            System.out.println(str.charAt(5));
        }catch(NullPointerException e){
            System.out.println("抛出异常并捕获");
        }finally{
            System.out.println("finally代码块0 , 执行正常！");
        }


        try{
            String str=null;
            System.out.println(str.charAt(5));
        }catch(NullPointerException e){
            System.out.println("抛出异常并捕获");
        }finally{
            System.out.println("finally代码块1,执行");
        }

        try{
            String str=null;
            System.out.println(str.charAt(5));
        }finally{
            System.out.println("finally代码块2，执行");
        }


    }
}
